package main.java.design.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * <p>
 * 动态代理类，不再实现抽象角色，改为实现InvocationHandler
 * </p>
 *
 * @author : wangdejian
 * @version 1.0
 * @date : 2020/6/13 18:18
 */
public class DynamicProxyHandler implements InvocationHandler {

    private Object target;

    public DynamicProxyHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("jdk动态代理.....");
        Object o = method.invoke(target, args);

        return o;
    }
}
